package it.polimi.traveldream.web.beans.shared;

import it.polimi.traveldream.ejbclient.dtos.HotelDTO;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
import javax.faces.convert.FacesConverter;


@FacesConverter(forClass=HotelDTO.class,value="hotelConverter")
public class SelectHotelsConverter implements Converter {

	@Override
	public Object getAsObject(FacesContext context, UIComponent component, String value) {
		HotelDTO hotel = new HotelDTO();
		hotel.setId(Integer.parseInt(value));
		return hotel;
	}

	@Override
	public String getAsString(FacesContext context, UIComponent component, Object value) {
		return String.valueOf(((HotelDTO) value).getId());
	}

}
